package beans;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;


public class TabelaParsing {

	private static LinkedList<Regra> tabela = new LinkedList<Regra>();
	
	public static void inicializa(){//
	
		tabela.add(new Regra(1, 52, 1, new ArrayList<Integer>(Arrays.asList( 1,25,100,47,53,49,101))));
		tabela.add( new Regra(  2, 53,  2, new ArrayList<Integer>(Arrays.asList(54,57,59,102,62,64) ) ) );
		tabela.add( new Regra(  2, 53,  3, new ArrayList<Integer>(Arrays.asList(54,57,59,102,62,64) ) ) );
		tabela.add( new Regra(  2, 53,  4, new ArrayList<Integer>(Arrays.asList(54,57,59,102,62,64) ) ) );
		tabela.add( new Regra(  2, 53,  5, new ArrayList<Integer>(Arrays.asList(54,57,59,102,62,64) ) ) );
		tabela.add( new Regra(  2, 53,  6, new ArrayList<Integer>(Arrays.asList(54,57,59,102,62,64) ) ) );
		tabela.add( new Regra(  3, 54,  2, new ArrayList<Integer>(Arrays.asList( 2,55,47) ) ) );
		tabela.add( new Regra(  4, 55, 25, new ArrayList<Integer>(Arrays.asList(25,104,56) ) ) );
		tabela.add(new Regra(5, 56, 0, null));
		tabela.add( new Regra(  6, 56, 46, new ArrayList<Integer>(Arrays.asList(46,25,104,56) ) ) );
		tabela.add(new Regra ( 7, 54,0,null));
		tabela.add( new Regra(  8, 57,  3, new ArrayList<Integer>(Arrays.asList( 3,25,105,40,26,106,47,58) ) ) );
		tabela.add( new Regra(  9, 58,  0, null ) );
		tabela.add( new Regra( 10, 58, 25, new ArrayList<Integer>(Arrays.asList(25,105,40,26,106,47,58) ) ) );
		tabela.add( new Regra( 11, 57,  0, null ) );
		tabela.add( new Regra( 12, 59,  4, new ArrayList<Integer>(Arrays.asList( 4,107,55,39,61,47,60) ) ) );
		tabela.add( new Regra( 13, 60,  0, null ) );		
		tabela.add( new Regra( 14, 60, 25, new ArrayList<Integer>(Arrays.asList(55,39,61,47,60) ) ) );
		tabela.add( new Regra( 15, 59,  0, null ) );		
		tabela.add( new Regra( 16, 61,  8, new ArrayList<Integer>(Arrays.asList( 8) ) ) );
		tabela.add( new Regra( 17, 61,  9, new ArrayList<Integer>(Arrays.asList( 9,34,26,50,26,35,10, 8) ) ) );
		tabela.add( new Regra( 18, 62,  5, new ArrayList<Integer>(Arrays.asList( 5,25,108,63,47,109,53,47,110,62) ) ) );
		tabela.add( new Regra( 19, 62,  0, null ) );
		tabela.add( new Regra( 20, 63, 0, null ) );
		tabela.add( new Regra( 21, 63, 36, new ArrayList<Integer>(Arrays.asList(36,111,55,39,8,37) ) ) );
		tabela.add( new Regra( 22, 64,  6, new ArrayList<Integer>(Arrays.asList( 6,66,65, 7) ) ) );
		tabela.add( new Regra( 23, 65,  0, null ) );
		tabela.add( new Regra( 24, 65, 47, new ArrayList<Integer>(Arrays.asList(47,66,65) ) ) );
		tabela.add( new Regra( 25, 66, 25, new ArrayList<Integer>(Arrays.asList(25,112,67) ) ) );
		tabela.add( new Regra( 26, 67, 39, new ArrayList<Integer>(Arrays.asList(113,39,66) ) ) );
		tabela.add( new Regra( 27, 67, 34, new ArrayList<Integer>(Arrays.asList(68,114,38,77,115) ) ) );
		tabela.add( new Regra( 27, 67, 38, new ArrayList<Integer>(Arrays.asList(68,114,38,77,115) ) ) );
		tabela.add( new Regra( 28, 68, 0, null ) );
		tabela.add( new Regra( 29, 68, 34, new ArrayList<Integer>(Arrays.asList(34,77,35) ) ) );
		tabela.add( new Regra( 30, 66,  6, new ArrayList<Integer>(Arrays.asList(64) ) ) );
		tabela.add( new Regra( 31, 66,  0, null ) );		
		tabela.add( new Regra( 32, 66, 11, new ArrayList<Integer>(Arrays.asList(11,25,116,69,117) ) ) );
		tabela.add( new Regra( 33, 69,  0, null ) );		
		tabela.add( new Regra( 34, 69, 36, new ArrayList<Integer>(Arrays.asList(36,77,118,70,37) ) ) );
		tabela.add( new Regra( 35, 70, 0, null ) );
		tabela.add( new Regra( 36, 70, 46, new ArrayList<Integer>(Arrays.asList(46,77,118,70) ) ) );
		tabela.add( new Regra( 37, 66, 12, new ArrayList<Integer>(Arrays.asList(12,25) ) ) );
		tabela.add( new Regra( 38, 66, 13, new ArrayList<Integer>(Arrays.asList(13,77,120,14,66,71,121) ) ) );
		tabela.add( new Regra( 39, 71,  0, null ) );
	
		tabela.add( new Regra( 40, 71, 15, new ArrayList<Integer>(Arrays.asList(122,15,66) ) ) );
		tabela.add( new Regra( 41, 66, 16, new ArrayList<Integer>(Arrays.asList(16,123,77,124,17,66,125) ) ) );
		tabela.add( new Regra( 42, 66, 18, new ArrayList<Integer>(Arrays.asList(18,126,66,19,77,127) ) ) );
		tabela.add( new Regra( 43, 66, 20, new ArrayList<Integer>(Arrays.asList(20,128,36,72,74,37) ) ) );
		tabela.add( new Regra( 44, 72, 25, new ArrayList<Integer>(Arrays.asList(25,129,73) ) ) );
		tabela.add( new Regra( 45, 73,  0, null ) );
		
		tabela.add( new Regra( 46, 73, 34, new ArrayList<Integer>(Arrays.asList(34,77,35) ) ) );
		tabela.add( new Regra( 47, 74, 0, null ) );
		tabela.add( new Regra( 48, 74, 46, new ArrayList<Integer>(Arrays.asList(46,72,74) ) ) );
		tabela.add( new Regra( 49, 66, 21, new ArrayList<Integer>(Arrays.asList(21,36,75,76,37) ) ) );
		tabela.add( new Regra( 50, 75, 48, new ArrayList<Integer>(Arrays.asList(48,130) ) ) );
		tabela.add( new Regra( 51, 75, 24, new ArrayList<Integer>(Arrays.asList(77,131) )) );
		tabela.add( new Regra( 51, 75, 25, new ArrayList<Integer>(Arrays.asList(77,131) ) ) );
		tabela.add( new Regra( 51, 75, 26, new ArrayList<Integer>(Arrays.asList(77,131) ) ) );
		tabela.add( new Regra( 51, 75, 30, new ArrayList<Integer>(Arrays.asList(77,131) ) ) );
		tabela.add( new Regra( 51, 75, 31, new ArrayList<Integer>(Arrays.asList(77,131) ) ) );
		tabela.add( new Regra( 51, 75, 36, new ArrayList<Integer>(Arrays.asList(77,131) ) ) );
		tabela.add( new Regra( 52, 76, 0, null ) );
		tabela.add( new Regra( 53, 76, 46, new ArrayList<Integer>(Arrays.asList(46,75,76) ) ) );
		tabela.add( new Regra( 54, 66, 29, new ArrayList<Integer>(Arrays.asList(29,132,77,10,84,7,133) ) ) );
		tabela.add( new Regra( 55, 84, 26, new ArrayList<Integer>(Arrays.asList(26,86,39,134,66,135,85) ) ) );
		tabela.add( new Regra( 56, 86, 46, new ArrayList<Integer>(Arrays.asList(46,136,26,86) ) ) );
		tabela.add( new Regra( 57, 86, 0, null ) );
		tabela.add( new Regra( 58, 85,  0, null ) );
		tabela.add( new Regra( 59, 85, 47, new ArrayList<Integer>(Arrays.asList(47,84) ) ) );
		tabela.add( new Regra( 60, 66, 27, new ArrayList<Integer>(Arrays.asList(27,25,137,38,77,138,28,77,139,17,66,140) ) ) );
		tabela.add( new Regra( 61, 77, 24, new ArrayList<Integer>(Arrays.asList(79,78) ) ) );
		tabela.add( new Regra( 61, 77, 25, new ArrayList<Integer>(Arrays.asList(79,78) ) ) );
		tabela.add( new Regra( 61, 77, 26, new ArrayList<Integer>(Arrays.asList(79,78) ) ) );
		tabela.add( new Regra( 61, 77, 30, new ArrayList<Integer>(Arrays.asList(79,78) ) ) );
		tabela.add( new Regra( 61, 77, 31, new ArrayList<Integer>(Arrays.asList(79,78) ) ) );
		tabela.add( new Regra( 61, 77, 36, new ArrayList<Integer>(Arrays.asList(79,78) ) ) );	
		tabela.add( new Regra( 62, 78, 0, null ) );		
		tabela.add( new Regra( 63, 78, 40, new ArrayList<Integer>(Arrays.asList(40,79,141) ) ) );
		tabela.add( new Regra( 64, 78, 43, new ArrayList<Integer>(Arrays.asList(43,79,142) ) ) );
		tabela.add( new Regra( 65, 78, 41, new ArrayList<Integer>(Arrays.asList(41,79,143) ) ) );
		tabela.add( new Regra( 66, 78, 42, new ArrayList<Integer>(Arrays.asList(42,79,144) ) ) );
		tabela.add( new Regra( 67, 78, 44, new ArrayList<Integer>(Arrays.asList(44,79,145) ) ) );
		tabela.add( new Regra( 68, 78, 45, new ArrayList<Integer>(Arrays.asList(45,79,146) ) ) );
		tabela.add( new Regra( 69, 79, 30, new ArrayList<Integer>(Arrays.asList(30,81,80) ) ) );
		tabela.add( new Regra( 70, 79, 31, new ArrayList<Integer>(Arrays.asList(31,81,147,80) ) ) );
		tabela.add( new Regra( 71, 79, 24, new ArrayList<Integer>(Arrays.asList(81,80) ) ) );
		tabela.add( new Regra( 71, 79, 25, new ArrayList<Integer>(Arrays.asList(81,80) ) ) );
		tabela.add( new Regra( 71, 79, 26, new ArrayList<Integer>(Arrays.asList(81,80) ) ) );
		tabela.add( new Regra( 71, 79, 36, new ArrayList<Integer>(Arrays.asList(81,80) ) ) );
		tabela.add( new Regra( 72, 80, 30, new ArrayList<Integer>(Arrays.asList(30,81,148,80) ) ) );
		tabela.add( new Regra( 73, 80, 31, new ArrayList<Integer>(Arrays.asList(31,81,149,80) )) );
		tabela.add( new Regra( 74, 80, 22, new ArrayList<Integer>(Arrays.asList(22,81,150,80) ) ) );
		tabela.add( new Regra( 75, 80,  0, null ) );		
		tabela.add( new Regra( 76, 81, 24, new ArrayList<Integer>(Arrays.asList(83,82) ) ) );
		tabela.add( new Regra( 76, 81, 25, new ArrayList<Integer>(Arrays.asList(83,82) ) ) );
		tabela.add( new Regra( 76, 81, 26, new ArrayList<Integer>(Arrays.asList(83,82) ) ) );
		tabela.add( new Regra( 76, 81, 36, new ArrayList<Integer>(Arrays.asList(83,82) ) ) );
		tabela.add( new Regra( 77, 82,  0, null ) );		
		tabela.add( new Regra( 78, 82, 32, new ArrayList<Integer>(Arrays.asList(32,83,151,82) ) ) );
		tabela.add( new Regra( 79, 82, 33, new ArrayList<Integer>(Arrays.asList(33,83,152,82) ) ) );
		tabela.add( new Regra( 80, 82, 23, new ArrayList<Integer>(Arrays.asList(23,83,82) ) ) );
		tabela.add( new Regra( 81, 83, 26, new ArrayList<Integer>(Arrays.asList(26,154) ) ) );
		tabela.add( new Regra( 82, 83, 24, new ArrayList<Integer>(Arrays.asList(36,77,37) ) ) );
		tabela.add( new Regra( 83, 83, 24, new ArrayList<Integer>(Arrays.asList(24,83,155) ) ) );
		tabela.add( new Regra( 84, 83, 25, new ArrayList<Integer>(Arrays.asList(156,72) ) ) );
		
		
	}
	
	public static Regra procuraRegra(int codigoNaoTerminal, int codigoTerminal){
		for (Regra r:tabela){
			if(r.getCodigoNaoTerminal()== codigoNaoTerminal && r.getCodigoTerminal() == codigoTerminal)
				return r;			
		}
		return null;
	}
	
	public static boolean verificaSeAceitaVazio(int codigoNaoTerminal){
		for(Regra r:tabela){
			if(r.getCodigoNaoTerminal() == codigoNaoTerminal || r.getCodigoTerminal() ==0)
				return true;
		}
		return false;
	}
	
	
	
}
